import RobotError from "../errors/robot-error.js";
import Player from "../player/player.js";
import Item from "./item.js";
import Prop from "./prop.js";




/**还魂丹 复活用 */
export default class HalfHpMedicine extends Prop {
	intro: string = "未死亡时才可使用，使用后可立即恢复总生命值50%的血量";

	constructor() {
		super("半血丸");
	}

	use(user: Player): { msg: string; } {
		if (!user.isAlive()) throw new RobotError("你已经死了，无法使用");
		user.hpRatio += 0.5;
		if (user.hpRatio > 1) user.hpRatio = 1;
		return {
			msg: `成功使用半血丸，现在你有${user.currentHp}点血量`
		};
	}
}

